package com.example.demo.util;/**
 * 类描述 执行定时任务的线程池配置类
 * @author 8522
 * @date 2021/10/8 16:27
 * 版权所有 Copyright www.dahantc.com
 */

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 *@Description:
 *@Author: 8522
 *@Date: 2021/10/8  16:27
 *@Version v1.0
 */
@Configuration
public class SchedulingConfig {
    @Bean
    public TaskScheduler taskScheduler() {
        System.out.println("--------------------------------");
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        // 定时任务执行线程池核心线程数
        taskScheduler.setPoolSize(4);
        taskScheduler.setRemoveOnCancelPolicy(true);
        taskScheduler.setThreadNamePrefix("TaskSchedulerThreadPool-");
        return taskScheduler;
    }
}